package cn.wanda.bi.sunshine.platform.server.aspect;

import java.util.Arrays;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import cn.wanda.bi.sunshine.platform.server.SunshineCode;
import cn.wanda.bi.sunshine.platform.server.bean.KeyCommon;
import cn.wanda.bi.sunshine.platform.server.utils.exception.SunshineException;

/**
 * Created by wangfupeng1 on 2017-5-6.
 */
@Aspect
@Component
@Order(-1)
public class CheckLimitAop {

    @Autowired
    private HttpServletRequest request;
    
    @Before("@annotation(cn.wanda.bi.sunshine.platform.server.aspect.CheckLimit)")
    public void checkLimit(JoinPoint joinPoint) throws Throwable {
    	String limit = request.getParameter("limit");
    	if(Integer.valueOf(limit)>KeyCommon.LIMIT_UP_VALUE) {
    		throw new SunshineException(SunshineCode.LIMIT_UP_TO_2000);
    	}
    }
    
}
